/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.io.*;
import java.util.List;


import interfaces.*;
/**
 *
 * @author Luk
 */
public abstract class FileProcessor {
    protected BufferedReader stream;
    List<ITransaction> transactions;
    
    
    protected void openFile(String path) throws Exception{
        stream = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path))));
           
    }
    
    protected abstract void processTransactions() throws Exception;
    
    protected void closeFile() throws Exception{
        stream.close();
    }
    
    public List<ITransaction> getTransactions(String path) throws Exception{
        openFile(path);
        processTransactions();
        closeFile();
        return transactions;
    }
}
